/*
** put_in_tab.c for 42sh in /home/demesy_j/svn/quarante-deuxsh/trunk
** 
** Made by julien demesy
** Login   <demesy_j@epitech.net>
** 
** Started on  Tue Mar 13 17:19:47 2012 julien demesy
** Last update Wed Mar 14 19:36:31 2012 julien demesy
*/

#include	<stdlib.h>
#include	<string.h>
#include	"list.h"

static	int	get_tab_size(t_list *env)
{
  int		i;
  t_list	*it;

  it = env->next;
  i = 1;
  while (it != env)
    {
      i++;
      it = it->next;
    }
  return (i);
}

char		**get_env_tab(t_list *env)
{
  t_list	*it;
  char		**tab;
  int		i;

  it = env->next;
  tab = malloc((get_tab_size(env) + 1) * sizeof(char*));
  i = 0;
  while (it != env)
    {
      tab[i] = strdup(it->data);
      it = it->next;
      i++;
    }
  tab[i] = NULL;
  return (tab);
}
